package com.zhongya.example.fragment.advanced

import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.zhongya.example.R
import com.zhongya.example.adapter.ExampleAdapter
import com.zhongya.example.bean.ExampleBean
import com.zhongya.example.databinding.ExampleFragmentAdvancedBinding
import com.zhongya666.library.base.fragment.BaseDbFragment
import com.zhongya666.library.ext.initClose
import com.zhongya666.library.view.nav
import com.zhongya666.library.view.navigateAction

class AdvancedFragment : BaseDbFragment<ExampleFragmentAdvancedBinding>(R.layout.example_fragment_advanced) {

    override fun initView() {
        mDatabind.include.toolbar.initClose("进阶之光") {
            nav().popBackStack()
        }

        val list = arrayListOf<ExampleBean>()
        val bean1 = ExampleBean("第一章", "通知")
        val bean2 = ExampleBean("第二章", "TextInputLayout,")
        val bean9 = ExampleBean("第九章", "注解,")

        list.add(bean1)
        list.add(bean2)
        list.add(bean9)

        val adapter = ExampleAdapter(list)
        mDatabind.rv.adapter = adapter
        mDatabind.rv.layoutManager =
            StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL)

        adapter.setOnItemClickListener { adapter, view, position ->
            when (position) {
                0 -> {
                    nav().navigateAction(R.id.action_advancedFragment_to_jjzg1Fragment)
                }
                1 -> {
                    nav().navigateAction(R.id.action_advancedFragment_to_JJZG2Fragment)
                }
                2 -> {
                    nav().navigateAction(R.id.action_advancedFragment_to_JJZG9Fragment)
                }

            }
        }
    }

    override fun createObserver() {

    }

    override fun lazyLoadData() {

    }
}